﻿namespace Vinno.WMS.Pack.EntityConfiguration
{
    /// <summary>
    /// 文件内容实体映射配置
    /// </summary>
    public class WareHouseAreaConfiguration : EntityTypeConfigurationBase<WareHouseArea, Guid>
    {
        /// <summary>
        /// 获取 所属的数据上下文类型
        /// </summary>
        public override Type DbContextType => typeof(WMSDbContext);

        /// <summary>
        /// 重写以实现实体类型各个属性的数据库配置
        /// </summary>
        /// <param name="builder">实体类型创建器</param>
        public override void Configuration(EntityTypeBuilder<WareHouseArea> builder)
        {
            builder.HasIndex(m => new { m.WareHouseId, m.AreaName }).SetIndex("WareHouseAreaName", true);

            builder.HasOne(e => e.WareHouse).WithMany(d => d.WareHouseAreas)
                .HasForeignKey(d => d.WareHouseId).SetForeignKey("WareHouseId", true);
        }
    }
}
